Help:Variable

From PyroGuide

Jump to: navigation, search

Template:H:h

This is a list of variables that can be used in the wikitext. The way they are rendered depends on the time, on the project, or on the page in which it occurs.

On the left is the variable, on the right how it is rendered at this time, in this project, on this page.

The names of the variables form part of the set of so-called "magic words" the system uses.

Contents

[edit] Constants depending on parameters

{{ns:-2}}, {{ns:Media}} Media, Media
{{ns:-1}}, {{ns:Special}} Special, Special
{{ns:0}} ( main namespace ) ( empty string )
{{ns:1}}, {{ns:Talk}} Talk, Talk
{{ns:2}}, {{ns:User}} User, User
{{ns:3}}, {{ns:User_talk}} User_talk, User_talk
{{ns:4}}, {{ns:Project}} PyroGuide, PyroGuide
{{ns:5}}, {{ns:Project_talk}} PyroGuide_talk, PyroGuide_talk
{{ns:6}}, {{ns:Image}} Image, Image
{{ns:7}}, {{ns:Image_talk}} Image_talk, Image_talk
{{ns:8}}, {{ns:MediaWiki}} MediaWiki, MediaWiki
{{ns:9}}, {{ns:MediaWiki_talk}} MediaWiki_talk, MediaWiki_talk
{{ns:10}}, {{ns:Template}} Template, Template
{{ns:11}}, {{ns:Template_talk}} Template_talk, Template_talk
{{ns:12}}, {{ns:Help}} Help, Help
{{ns:13}}, {{ns:Help_talk}} Help_talk, Help_talk
{{ns:14}}, {{ns:Category}} Category, Category
{{ns:15}}, {{ns:Category_talk}} Category_talk, Category_talk
{{ns:100}}, {{ns:102}}, etc. , , etc. ( customized namespaces )
{{ns:101}}, {{ns:103}}, etc. , , etc.
{{SITENAME}} PyroGuide
{{SERVER}} http://pyroguide.com
{{SERVERNAME}} pyroguide.com
{{localurl:fullpagename}} /index.php?title=Fullpagename
{{localurl:a&b!}}
{{localurle:a&b!}}
/index.php?title=A%26b%21
/index.php?title=A%26b%21
{{localurl:page|query=x}} /index.php?title=Page&query=x
{{fullurl:fullpagename}} http://pyroguide.com/index.php?title=Fullpagename
{{fullurl:a&b!|u=v}}
{{fullurle:a&b!|u=v}}
http://pyroguide.com/index.php?title=A%26b%21&u=v
http://pyroguide.com/index.php?title=A%26b%21&u=v

The pseudo-template localurl<tt> replaces spaces by underscores and special characters by escape codes, e.g. {{localurl:a !}} gives /index.php?title=A_%21. Two purposes are:

  1. for a given page name, creating a link in external link style to a page in the same project or a project which uses the same string in the URL between the server name and the page name (on Wikimedia "/wiki/" and "w/index.php?title="),
  2. allow the same wikitext to be used in a project that uses a different string, if the target is in that other project or a project which uses the same string.

Note that <tt>localurl does not escape text in the query string after "|". This problem can be avoided by moving queries to the left hand side. In some cases, such as with Special:Contributions and Special:Recentchangeslinked the data can be placed after a "/", rather than as part of a query, Example:

http://meta.wikimedia.org/wiki/Special:Contributions?target=Jimbo_Wales&limit=10
as {{fullurl:m:Special:Contributions/Jimbo Wales|limit=10}} for
http://pyroguide.com/index.php?title=M:Special:Contributions/Jimbo_Wales&limit=10 but not
{{fullurl:m:Special:Contributions|target=Jimbo Wales&limit=10}} for
http://pyroguide.com/index.php?title=M:Special:Contributions&target=Jimbo Wales&limit=10.

Localurle and its counterpart fullurle perform additional character escaping on the resulting link, are intended for internal use only, and work in wikitext only for backwards-compatibility reasons. The unescaped versions should always be used in wikitext.

The {{fullurl}} pseudo-template introduced in recent versions of MediaWiki is a shorthand for {{SERVER}}{{localurl}}.

[edit] Varying with time

{{CURRENTYEAR}} 2012   {{CURRENTMONTH}} 06
{{CURRENTMONTHNAME}} June   {{CURRENTMONTHABBREV}} Jun
{{CURRENTMONTHNAMEGEN}} June   {{CURRENTWEEK}} 23
{{CURRENTDAY}} 8   {{CURRENTDAY2}} 08
{{CURRENTDAYNAME}} Friday   {{CURRENTDOW}} 5
{{CURRENTTIME}} 22:07   {{NUMBEROFARTICLES}} 539
{{REVISIONID}} 1779   {{NUMBEROFFILES}} 714

NUMBEROFARTICLES: number of pages in the main namespace which contain a link and are not a redirect, i.e. number of articles, stubs containing a link, and disambiguation pages.

This depends on system variable $wgUseCommaCount If true, article count will only include those with commas (","). If false, will only count those with links ("[["). The default set in DefaultSettings.php is false, this can be changed in LocalSettings.php. See also Help:Article count.

CURRENTWEEK ranges from 1 to 54 Template:Unclear. CURRENTMONTHNAMEGEN is the genitive grammatical form of the month name (used in Finnish). CURRENTDAY2 adds a leading zero to days 1...9, this allows to construct the ISO date formats like 2012-06-08T22:07Z.

[edit] Includeonly subst magic

When a template containing {{<includeonly>subst:</includeonly>CURRENTTIME}} is substituted, the time of doing that is put in the wikitext, and similarly for other variables. Examples:

{{CURRENTTIME}}
22:07 - is a variable on pages including the template
{{subst:CURRENTTIME}}
21:25 - became a substituted constant in the template
{{<includeonly>subst:</includeonly>CURRENTTIME}}
22:07 - becomes a constant at the time of its inclusion

[edit] Depending on page

{{NAMESPACE}} Help   {{NAMESPACEE}} Help
{{PAGENAME}} Variable   {{PAGENAMEE}} Variable
{{FULLPAGENAME}} Help:Variable   {{FULLPAGENAMEE}} Help:Variable
{{SUBPAGENAME}} Variable   {{SUBPAGENAMEE}} Variable

{{NAMESPACE}} and {{NAMESPACEE}} both return nothing (not even a space) in the article namespace.

PAGENAMEE displays the page title in the form that is used in URLs, i.e. with underscores for spaces, and escape codes for special characters, and is therefore used for constructing URLs. For example, on a page called "Grand café", PAGENAMEE would produce "Grand_caf%C3%A9". Do not use PAGENAMEE as the pagename in first part of the variable localurl, see above.

When used in a template, these eight variables refer to the page in which the template is included, not to the template page.

[edit] Depending on revision

{{REVISIONID}} gives 1779

REVISIONID displays a unique number identifying a version of a page in the set of all versions of all pages. In the URL the number can be referred to as "oldid=..", even when the version is still the current one. This can be useful on talk pages, and for citation in newspaper, scholar works, etc. When applying such a URL, at the top of the page the date and local time (if not logged in: UTC) are displayed, with a link to the previous version, and a link to the next version (unless at the time of loading the page there is no newer version: in that case the text "Newer revision" appears anyway, but it is not a link; if the version is the first, a link labeled "previous revision" appears anyway, but it leads to the same page)

The page history page and the Permalinks also use this variable. In a preview, the REVISIONID is not defined.

[edit] Examples of combinations

{{fullurl:{{FULLPAGENAME}}|action=edit}}
http://pyroguide.com/index.php?title=Help:Variable&action=edit
 
{{fullurl:Special:Whatlinkshere|target={{NAMESPACE}}:{{PAGENAME}}}}
http://pyroguide.com/index.php?title=Special:Whatlinkshere&target=Help:Variable
 
{{fullurl:{{NAMESPACE}}:{{PAGENAME}}|action=edit}}
http://pyroguide.com/index.php?title=Help:Variable&action=edit
 
{{fullurl:Special:Whatlinkshere|target={{NAMESPACE}}:{{PAGENAME}}}}
http://pyroguide.com/index.php?title=Special:Whatlinkshere&target=Help:Variable
 
[[{{NAMESPACE}}:{{PAGENAME}}_1]]
Help:Variable_1
 
{{fullurl:{{NAMESPACE}}:{{PAGENAME}}_1}}
http://pyroguide.com/index.php?title=Help:Variable_1
 
{{fullurl:{{NAMESPACE}}:{{PAGENAME}}|oldid={{REVISIONID}}}}
http://pyroguide.com/index.php?title=Help:Variable&oldid=1779
 

The old form {{SERVER}}{{localurl:page }} has the same effect as {{fullurl:page }} in recent (1.5+) versions of the software.

As a link the last example is not useful in the page itself, but it gives useful info about the original in a paper or HTML copy of the page, and provides a permalink to that in the HTML copy.

In a template, for a link to a page which depends on a template parameter, the external link style is used even for internal links, to avoid that the system links to the edit page even if the page exists. To construct the external link, variables can also be useful.

[edit] See also

Template:H:f

Personal tools
pyroguide forum
pyroguide sponsors
pyroguide visitors